package com.example.bookshelf.data

import com.example.bookshelf.network.BookApiService
import junit.framework.TestCase.assertEquals
import kotlinx.coroutines.test.runTest
import org.junit.Test
import retrofit2.Retrofit
import retrofit2.converter.scalars.ScalarsConverterFactory

class BookShelfRepositoryTest {
    private val baseUrl = "https://www.googleapis.com/"
    private val retrofit = Retrofit.Builder()
        .addConverterFactory(ScalarsConverterFactory.create())
        .baseUrl(baseUrl)
        .build()
    private val retrofitService : BookApiService by lazy {
        retrofit.create(BookApiService::class.java)
    }

    @Test
    fun networkBookShelfRepository_getBooks_verifyBooks() {
        val repository = NetworkBookShelfRepository(retrofitService)
        runTest {
            val books = repository.getBooks("jazz+history")
            assertEquals(10, books.size)
        }
    }
}